package nl.xs4all.dylanschell.deckprinter.guice;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.apache.wicket.protocol.http.IWebApplicationFactory;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WicketFilter;

@Singleton
public class WicketGuiceFilter extends WicketFilter
{
    private final Provider<WebApplication> appsProvider;

    @Inject
    public WicketGuiceFilter(Provider<WebApplication> appsProvider)
    {
        this.appsProvider = appsProvider;
    }

    @Override
    protected IWebApplicationFactory getApplicationFactory()
    {
        return new IWebApplicationFactory()
        {
            public WebApplication createApplication(WicketFilter filter)
            {
                return appsProvider.get();
            }
        };
    }
}
